//
//  ViewController.m
//  DevicePrepaireReportFour
//
//  Created by MacBook Pro on 16/8/1.
//  Copyright © 2016年 guotongbo. All rights reserved.
//
//屏幕的宽
#define SCREENW self.view.bounds.size.width
//屏幕的高
#define SCREENH self.view.bounds.size.height
#define Margin 5
#define LineLen 1;
// RGB颜色
#define TBColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]

#import "DevicePrepaireReportFourViewControlller.h"
#import "BorderButton.h"
#import "NrowLabelMessage.h"
#import "NrowLabelViewCell.h"
#import "RSCheckBox.h"
#import "RSCheckGroup.h"
#import "MyButton.h"
#import "TouchView.h"
@interface DevicePrepaireReportFourViewControlller ()<UITableViewDelegate,UITableViewDataSource,UIPickerViewDelegate,UIPickerViewDataSource>
/**邮箱*/
@property(nonatomic,strong)UIButton *emailBtn;
/**邮箱线*/
@property(nonatomic,strong)UIView *emailLine;
/**邮件地址Label*/
@property(nonatomic,strong)UILabel *emailLabel;
/**保存*/
@property(nonatomic,strong)BorderButton *saveBtn;
/**提交 */
@property(nonatomic,strong)BorderButton *sumbitBtn;
/**数据*/
@property(nonatomic,strong)NSArray *info;
/**区头*/
@property(nonatomic,strong)NSMutableDictionary *header;
/**设备名称数组*/
@property(nonatomic,strong)NSArray *deviceNameArr;
/**设备名称Btn*/
@property(nonatomic,strong)UIButton *deviceNameBtn;
/**设备名称字符串*/
@property(nonatomic,strong)NSString *deviceNameStr;
/**设备名称按钮类型View*/
@property(nonatomic,strong)UIPickerView *singleView;
/**区脚View*/
@property(nonatomic,strong)UIView *footView;
/**tableView*/
@property(nonatomic,strong)UITableView *tableV;
/**仪器随机标准配件是否齐全*/
@property(nonatomic,assign)BOOL isMachineParts;
/**电源是否具有接地*/
@property(nonatomic,assign)BOOL isPowerConnect;
/**工作台是否符合要求*/
@property(nonatomic,assign)BOOL isWorkBench;
/**配备UPS*/
@property(nonatomic,assign)BOOL isUPS;
/**配备空调*/
@property(nonatomic,assign)BOOL isEquipAirCondition;
/**安装场地空间符合要求*/
@property(nonatomic,assign)BOOL isFitGround;
@end

@implementation DevicePrepaireReportFourViewControlller
/**邮箱*/
@synthesize emailBtn;
/**邮箱线*/
@synthesize emailLine;
/**邮件地址Label*/
@synthesize emailLabel;
/**保存*/
@synthesize saveBtn;
/**提交 */
@synthesize sumbitBtn;
/**数据容器*/
@synthesize info;
/**区头*/
@synthesize header;
/**设备名称数组*/
@synthesize deviceNameArr;
/**设备名称Btn*/
@synthesize deviceNameBtn;
/**设备名称字符串*/
@synthesize deviceNameStr;
/**设备名称按钮类型View*/
@synthesize singleView;
/**区脚View*/
@synthesize footView;
/**tableView*/
@synthesize tableV;
/**仪器随机标准配件是否齐全*/
@synthesize isMachineParts;
/**电源是否具有接地*/
@synthesize isPowerConnect;
/**工作台是否符合要求*/
@synthesize isWorkBench;
/**配备UPS*/
@synthesize isUPS;
/**配备空调*/
@synthesize isEquipAirCondition;
/**安装场地空间符合要求*/
@synthesize isFitGround;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.title = @"设备维修单";
    self.view.backgroundColor = [UIColor whiteColor];
    //取数据
    [self GetData];
    //搭建界面
    [self setUpInterface];
    //改变导航栏的颜色、字体
    [self initNav];

}
-(void)initNav{
    
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:93/255.0 green:199/255.0 blue:255/255.0 alpha:1.0]];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,nil]];
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    
}
//取数据
-(void)GetData{
    NSString *path = [[NSBundle mainBundle]pathForResource:@"DevicePrepaireReportFour" ofType:@"plist"];
    info = [NSArray arrayWithContentsOfFile:path];
    
    header = [NSMutableDictionary dictionary];
}
//搭建界面
-(void)setUpInterface{
    
    //top和下面的按钮
    [self setUpBaseInfo];
    tableV = [[UITableView alloc]initWithFrame:CGRectMake(0,emailLine.frame.origin.y + 2 , SCREENW, saveBtn.frame.origin.y - emailLine.frame.origin.y + 1)style:UITableViewStyleGrouped];
    tableV.separatorStyle = NO;
    tableV.delegate = self;
    tableV.dataSource = self;
    
    //tableV.style = UITableViewStyleGrouped;
    [self.view addSubview:tableV];
    // 设置额外滚动区域
    //tableV.contentInset = UIEdgeInsetsMake(0, 0, 50, 0);
}
//基本信息
-(void)setUpBaseInfo{
    //邮箱
    emailBtn = [[UIButton alloc]init];
    [emailBtn setImage:[UIImage imageNamed:@"c_7"] forState:UIControlStateNormal];
    CGFloat emailBtnX = SCREENW - 45;
    CGFloat emailBtnY = 69;
    CGFloat emailBtnW = 32;
    CGFloat emailBtnH = 32;
    emailBtn.frame = CGRectMake(emailBtnX, emailBtnY, emailBtnW, emailBtnH);
    [emailBtn addTarget:self action:@selector(sendEmail) forControlEvents:UIControlEventTouchUpInside ];
    
    [self.view addSubview:emailBtn];
    
    //邮箱线
    emailLine = [[UIView alloc]init];
    emailLine.backgroundColor = TBColor(212, 212, 212, 1);
    CGFloat emailLineX = 0;
    CGFloat emailLineY = emailBtnY + emailBtnH + Margin;
    CGFloat emailLineW = SCREENW;
    CGFloat emailLineH = LineLen;
    emailLine.frame = CGRectMake(emailLineX, emailLineY, emailLineW, emailLineH);
    [self.view addSubview:emailLine];
    
    //保存
    saveBtn = [BorderButton buttonWithType:UIButtonTypeCustom];
    saveBtn.backgroundColor = TBColor(5, 206, 114, 1);
    CGFloat saveBtnX = 1;
    CGFloat saveBtnY = SCREENH - 64;
    CGFloat saveBtnW = SCREENW / 2 -1;
    CGFloat saveBtnH = 64;
    saveBtn.frame = CGRectMake(saveBtnX, saveBtnY, saveBtnW, saveBtnH);
    [saveBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    [saveBtn setTitle:@"保存" forState:UIControlStateNormal];
    [self.view addSubview:saveBtn];
    
    //提交
    sumbitBtn = [BorderButton buttonWithType:UIButtonTypeCustom];
    sumbitBtn.backgroundColor = TBColor(5, 206, 114, 1);
    CGFloat sumbitBtnX = saveBtnW + 2;
    CGFloat sumbitBtnY = saveBtnY;
    CGFloat sumbitBtnW = saveBtnW - 1;
    CGFloat sumbitBtnH = saveBtnH;
    sumbitBtn.frame = CGRectMake(sumbitBtnX, sumbitBtnY, sumbitBtnW, sumbitBtnH);
    [sumbitBtn setTitle:@"提交" forState:UIControlStateNormal];
    [sumbitBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    [self.view addSubview:sumbitBtn];
    
    UILabel *titleL = [[UILabel alloc]initWithFrame:CGRectMake(0, 69, SCREENW - emailBtnW - 20, emailBtnH)];
    titleL.font = [UIFont boldSystemFontOfSize:17];
    titleL.text = @"           仪器安装报告";
    titleL.textColor = [UIColor blackColor];
    titleL.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:titleL];
}
//点击邮件事件
-(void)sendEmail{
    
    UIView *emailView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, SCREENH)];
    emailView.tag = 7;
    emailView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:emailView];
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(18, SCREENW / 3, SCREENW - 36, 150)];
    view.layer.backgroundColor = TBColor(94, 204, 250, 1).CGColor;
    view.layer.borderWidth = 1;
    view.backgroundColor = [UIColor whiteColor];
    [emailView addSubview:view];
    
    emailLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 5, SCREENW - 105, 30)];
    emailLabel.text = @"请输入邮箱地址:";
    [view addSubview:emailLabel];
    
    UITextField *textF = [[UITextField alloc]initWithFrame:CGRectMake(20, 40, SCREENW * 4/5, 30)];
    textF.backgroundColor = TBColor(212, 212, 212, 1);
    [view addSubview:textF];
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(SCREENW * 4/5 - 80, 90, 80, 30)];
    [btn setTitle:@"发送" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    btn.backgroundColor = TBColor(102, 85, 191, 1);
    [btn addTarget:self action:@selector(send) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn];
    
    UIButton *cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, 90, 80, 30)];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [cancelBtn setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    cancelBtn.backgroundColor = TBColor(102, 85, 191, 1);
    [cancelBtn addTarget:self action:@selector(cancel) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:cancelBtn];
    
    
}
//点击取消按钮
-(void)cancel{
    UIView *subViews = [self.view viewWithTag:7];
    [subViews removeFromSuperview];
}
//点击发送邮件按钮
-(void)send{
    
    UIApplication *app = [UIApplication sharedApplication];
    NSURL *url = [NSURL URLWithString:emailLabel.text];
    //[app openURL:url];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return info.count;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    NSArray *groupInfo = info[section][@"info"];
    return groupInfo.count;
}
#pragma mark 创建每一行的cell
//给cell赋值
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //根据类创建cell
    NrowLabelViewCell *cell = [NrowLabelViewCell NrowLabelMessageViewWithTableView:tableView];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //根据行号取出模型，赋值
    NSString *str =info[indexPath.section][@"info"][indexPath.row];
    NSLog(@"%@",str);
    cell.infoLabel.text =info[indexPath.section][@"info"][indexPath.row];
    
    return  cell;
}
//设置cell的高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 82;
}
//设置区头
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW - 30, 50)];
    view.backgroundColor = [UIColor whiteColor];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(8, 0, SCREENW - 16, 50)];
    label.font = [UIFont boldSystemFontOfSize:17];
    label.text =[NSString stringWithFormat:@"  %@", info[section][@"header"]];
    
    [view addSubview:label];
    if (section == 2 || section == 5) {
        //设备名称（单选）
        if (section == 2) {
            deviceNameArr = [NSArray arrayWithObjects:@"Bact/ALERT 3D 60",@"Bact/ALERT 3D 120",@"Bact/ALERT 3D 240",@"PREVI Color Gram 12",@"PREVI Color Gram 30",@"MINI VIDAS",@"VIDAS 30",@"VIDAS 3",@"VITEK MS IVD",@"VITEK MS RUO（鉴定",@"VITEK MS RUO（建库）",@"VITEK 2",@"VITEK 2 XL",@"VITEK 2 COMPACT 15",@"VITEK 2 COMPACT  30",@"VITEK 2 COMPACT  60",@"手工试剂", nil];
            deviceNameBtn = [[UIButton alloc]initWithFrame:CGRectMake(18, 40, SCREENW - 36, 35)];
            [deviceNameBtn setTitle:deviceNameStr forState:UIControlStateNormal];
            [deviceNameBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
            deviceNameBtn.layer.borderColor = TBColor(202, 202, 202, 1).CGColor;
            deviceNameBtn.layer.borderWidth = 2;
            [deviceNameBtn addTarget:self action:@selector(DeviceNameClick) forControlEvents:UIControlEventTouchUpInside];
            [view addSubview:deviceNameBtn];
            
        }
        if (section == 5) {
            //工作内容
            UITextView *textV = [[UITextView alloc]initWithFrame:CGRectMake(21, 44, SCREENW - 42, 120)];
            textV.backgroundColor = TBColor(202, 202, 202, 1);
            [view addSubview:textV];

        }
        label.textColor = [UIColor blackColor];
        //左边的线
        UIView *leftL = [[UIView alloc]initWithFrame:CGRectMake(8, 0, 2, 200)];
        leftL.backgroundColor = TBColor(143, 143, 143, 1);
        //右边的线
        
        UIView *rightL = [[UIView alloc]initWithFrame:CGRectMake(SCREENW - 10, 0, 2, 200)];
        rightL.backgroundColor = TBColor(143, 143, 143, 1);
        
        [view addSubview:leftL];
        [view addSubview:rightL];
        return view;
        
    }
    else{
        label.textColor = TBColor(102, 85, 191, 1);
        label.layer.borderColor = TBColor(102, 85, 191, 1).CGColor;
        label.layer.borderWidth = 1;
        
        //左边的线
        UIView *leftL = [[UIView alloc]initWithFrame:CGRectMake(8, 0, 2, 50)];
        leftL.backgroundColor = TBColor(143, 143, 143, 1);
        //右边的线
        
        UIView *rightL = [[UIView alloc]initWithFrame:CGRectMake(SCREENW - 10, 0, 2, 50)];
        rightL.backgroundColor = TBColor(143, 143, 143, 1);
        
        [view addSubview:leftL];
        [view addSubview:rightL];
        
        
        [view addSubview:label];
        return view;
        
    }
    
    return view;
    
}
//设备名称点击事件生成View
-(void)DeviceNameClick{
    
    UIView *bigView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, SCREENH)];
    bigView.backgroundColor = [UIColor clearColor];
    bigView.tag = 8;
    [self.view addSubview:bigView];

    NSLog(@"设备点击了");
    
    singleView = [[UIPickerView alloc]initWithFrame:CGRectMake(10, SCREENH - saveBtn.bounds.size.height - 150, SCREENW - 20, 150)];
    singleView.tag = 1;
    singleView.backgroundColor = [UIColor whiteColor];
    singleView.delegate = self;
    singleView.dataSource = self;
    [bigView addSubview:singleView];
    
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    return deviceNameArr.count;
}
#pragma mark pickerView代理方法
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    
    return deviceNameArr[row];
    
}
// pickerView滚动结束时调用
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    if (singleView.tag == 1) {
        [deviceNameBtn setTitle:deviceNameArr[row] forState:UIControlStateNormal];
        deviceNameStr = deviceNameArr[row];
        UIView *subviews  = [self.view viewWithTag:8];
        [subviews removeFromSuperview];
    }
    
}
//设置区尾View
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    
    footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENW, 441)];
    footView.backgroundColor = [UIColor whiteColor];
    
    if (section == 0 || section == 1 || section == 4) {
        //左边的线
        UIView *lefLL = [[UIView alloc]initWithFrame:CGRectMake(8, 0, 2, 164)];
        lefLL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:lefLL];
        //右边的线
        UIView *rightL = [[UIView alloc]initWithFrame:CGRectMake(SCREENW - 10, 0, 2, 164)];
        rightL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:rightL];
    }
    //设备名称（单选）
    if (section == 2) {
        //左边的线
        UIView *lefLL = [[UIView alloc]initWithFrame:CGRectMake(8, 0, 2, 250)];
        lefLL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:lefLL];
        //右边的线
        UIView *rightL = [[UIView alloc]initWithFrame:CGRectMake(SCREENW - 10, 0, 2, 250)];
        rightL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:rightL];
        
        //仪器随机标准配件是否齐全？
        MyButton *isMachinePartsBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        isMachinePartsBtn.frame = CGRectMake(18, 20, SCREENW - 40, 30);
        [isMachinePartsBtn setTitle:@"仪器随机标准配件是否齐全？" forState:UIControlStateNormal];
        [isMachinePartsBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        isMachinePartsBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        isMachinePartsBtn.layer.borderWidth = 1;
        [isMachinePartsBtn addTarget:self action:@selector(isMachinePartsBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        isMachinePartsBtn.selected = isMachineParts;
        if (isMachinePartsBtn.selected ) {
            [isMachinePartsBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [isMachinePartsBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:isMachinePartsBtn];
        
        UILabel *directionL = [[UILabel alloc]initWithFrame:CGRectMake(18, 80, SCREENW - 40, 20)];
        directionL.text = @"请说明:";
        [footView addSubview:directionL];
        
        UITextView *directionFV = [[UITextView alloc]initWithFrame:CGRectMake(18, 110, SCREENW - 40, 120)];
        directionFV.backgroundColor = TBColor(202, 202, 202, 1);
        [footView addSubview:directionFV];
        
    }
    if (section == 3) {
        //左边的线
        UIView *lefLL = [[UIView alloc]initWithFrame:CGRectMake(8, 0, 2, 440)];
        lefLL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:lefLL];
        //右边的线
        UIView *rightL = [[UIView alloc]initWithFrame:CGRectMake(SCREENW - 10, 0, 2, 440)];
        rightL.backgroundColor =TBColor(160, 160, 160, 1);
        [footView addSubview:rightL];
        
        //电源是否具有接地
        MyButton *powerConnectBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        powerConnectBtn.frame = CGRectMake(18, 20, SCREENW - 40, 30);
        [powerConnectBtn setTitle:@"电源是否具有接地" forState:UIControlStateNormal];
        [powerConnectBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        powerConnectBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        powerConnectBtn.layer.borderWidth = 1;
        [powerConnectBtn addTarget:self action:@selector(powerConnectBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        powerConnectBtn.selected = isPowerConnect;
        if (powerConnectBtn.selected ) {
            [powerConnectBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [powerConnectBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:powerConnectBtn];
        
        //工作台是否符合要求
        MyButton *workbenchBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        workbenchBtn.frame = CGRectMake(18, 70, SCREENW - 40, 30);
        [workbenchBtn setTitle:@"电源是否具有接地" forState:UIControlStateNormal];
        [workbenchBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        workbenchBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        workbenchBtn.layer.borderWidth = 1;
        [workbenchBtn addTarget:self action:@selector(workbenchBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        workbenchBtn.selected = isWorkBench;
        if (workbenchBtn.selected ) {
            [workbenchBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [workbenchBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:workbenchBtn];
        
        //配备UPS：
        MyButton *UPSBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        UPSBtn.frame = CGRectMake(18, 120 , SCREENW - 40, 30);
        [UPSBtn setTitle:@"配备UPS" forState:UIControlStateNormal];
        [UPSBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        UPSBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        UPSBtn.layer.borderWidth = 1;
        [UPSBtn addTarget:self action:@selector(UPSBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        UPSBtn.selected = isUPS;
        if (UPSBtn.selected ) {
            [UPSBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [UPSBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:UPSBtn];
        
        //配备空调：
        MyButton *equipAirConditionBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        equipAirConditionBtn.frame = CGRectMake(18, 170 , SCREENW - 40, 30);
        [equipAirConditionBtn setTitle:@"配备空调" forState:UIControlStateNormal];
        [equipAirConditionBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        equipAirConditionBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        equipAirConditionBtn.layer.borderWidth = 1;
        [equipAirConditionBtn addTarget:self action:@selector(UPSBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        equipAirConditionBtn.selected = isEquipAirCondition;
        if (equipAirConditionBtn.selected ) {
            [equipAirConditionBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [equipAirConditionBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:equipAirConditionBtn];
        
        //安装场地空间是否符合要求
        MyButton *fitGroundBtn= [MyButton buttonWithType:UIButtonTypeCustom];
        fitGroundBtn.frame = CGRectMake(18, 220 , SCREENW - 40, 30);
        [fitGroundBtn setTitle:@"安装场地空间是否符合要求" forState:UIControlStateNormal];
        [fitGroundBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        fitGroundBtn.layer.borderColor = TBColor(212, 212, 212, 1).CGColor;
        fitGroundBtn.layer.borderWidth = 1;
        [fitGroundBtn addTarget:self action:@selector(fitGorundClick:) forControlEvents:UIControlEventTouchUpInside];
        fitGroundBtn.selected = isFitGround;
        if (fitGroundBtn.selected ) {
            [fitGroundBtn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
            
        }else{
            [fitGroundBtn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
        }
        
        [footView addSubview:fitGroundBtn];
        
        //备注
        UILabel *commentsL = [[UILabel alloc]initWithFrame:CGRectMake(18, 270, SCREENW - 40, 20)];
        commentsL.text = @"备注";
        [footView addSubview:commentsL];
        
        UITextView *commentsTV = [[UITextView alloc]initWithFrame:CGRectMake(18, 300, SCREENW - 40, 120)];
        commentsTV.backgroundColor = TBColor(212, 212, 212, 1);
        [footView addSubview:commentsTV];
    }
    
    
    return  footView;
}

//仪器随机标准配件是否点击事件
-(void)isMachinePartsBtnClick:(UIButton *)btn{
    
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
        
    }else{
        [btn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
    }
    isMachineParts = btn.selected;
    
}
//电源是否具有接地
-(void)powerConnectBtnClick:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
        
    }else{
        [btn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
    }
    isPowerConnect = btn.selected;
}
//工作台是否符合要求
-(void)workbenchBtnClick:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
        
    }else{
        [btn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
    }
    isWorkBench = btn.selected;
    
}
 //配备UPS
-(void)UPSBtnClick:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
        
    }else{
        [btn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
    }
    isEquipAirCondition = btn.selected;
}
//安装场地空间是否符合要求
-(void)fitGorundClick:(UIButton *)btn{
    btn.selected = !btn.selected;
    if (btn.selected) {
        [btn setImage:[UIImage imageNamed:@"checkbox1_checked"] forState:UIControlStateNormal];
        
    }else{
        [btn setImage:[UIImage imageNamed:@"checkbox1_unchecked"] forState:UIControlStateNormal];
    }
    isFitGround = btn.selected;

}
//区头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return 82;
    }else if (section == 5){
        return 155;
    }else if (section == 4){
        return 40;
    }
    return 50;
    
}
//区尾的高度
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 2) {
        return  250;
    }else if (section == 3){
        return 440;
    }else if (section == 4){
        return 0;
    }
    return 0;
}

@end
